package com.dev;
import android.app.Activity;
import android.content.Intent;
import android.widget.LinearLayout;
import android.os.Bundle;
import android.widget.TextView;
import android.graphics.Typeface;
import android.view.Gravity;
import android.view.KeyEvent;

public class ErrorActivity extends Activity {
    GUI gui;
    float dp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        dp=getResources().getDisplayMetrics().density;
        gui=new GUI(this);
        setContentView(gui);
        Intent intent=getIntent();
        if(intent!=null){
            onNewIntent(intent);
        }
    }
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        String err=intent.getStringExtra("error");
        if(err!=null){
            gui.message.setText(err+"\n"+intent.getStringExtra("thread"));
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        System.exit(1);
    }
    class GUI extends LinearLayout{
        TextView title;
        TextView message;
        ErrorActivity ea;
        GUI(ErrorActivity ea){
            super(ErrorActivity.this);
            this.ea=ea;
            setOrientation(VERTICAL);
            int padding=(int)(10*dp);
            title=new TextView(ea);
            title.setTextSize(17);
            title.setText("Exception:");
            title.setGravity(Gravity.CENTER_VERTICAL);
            title.setPadding(padding,0,0,0);
            message=new TextView(ea);
            message.setTypeface(Typeface.MONOSPACE);
            message.setTextSize(14);
            message.setTextColor(0xff000000);
            message.setPadding(padding,0,0,0);
            addView(title,-1,(int)(30*dp));
            addView(message,new LayoutParams(-1,0,1f));
        }
    }

    @Override
    public void onPointerCaptureChanged(boolean hasCapture) {
    }
    
}
